﻿using System;
using Microsoft.Practices.Prism.ViewModel;

namespace Warehouse.Silverlight.Core.Infrastructure.ViewModels
{
    public abstract class ViewModel : NotificationObject
    {
        // Must override
        protected abstract void Initialize();

        // Overridable
        protected virtual void Cleanup()
        {
        }

        #region IsBusy

        private int _busyCounter;
        protected int BusyCounter
        {
            get { return _busyCounter; }
            set
            {
                _busyCounter = value;
                RaisePropertyChanged(() => IsBusy);
            }
        }
        public bool IsBusy
        {
            get;// { return BusyCounter > 0; }
            protected set;
        }
        
        #endregion

        #region HasError

        private int _errorCounter;
        protected int ErrorCounter
        {
            get { return _errorCounter; }
            set
            {
                _errorCounter = value;
                RaisePropertyChanged(() => HasError);
            }
        }
        public bool HasError
        {
            get { return ErrorCounter > 0; }
        }
        
        #endregion

    }
}
